package ${package.Controller};

import io.swagger.annotations.Api;
<#if restControllerStyle>
import org.springframework.web.bind.annotation.RestController;
<#else>
import org.springframework.stereotype.Controller;
</#if>
<#if superControllerClassPackage??>
import ${superControllerClassPackage};
</#if>
import ${package.ServiceImpl}.${table.serviceImplName};
import ${package.Entity}.${entity};
import com.liqi.common.core.domain.PageData;
import com.liqi.common.core.domain.PageParam;
import com.liqi.common.core.domain.R;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author ${author}
 * @date ${date}
 */
@Api(tags = "${table.comment!}")
<#if restControllerStyle>
@RestController
<#else>
@Controller
</#if>
@RequestMapping("<#if package.ModuleName??>/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
<#if kotlin>
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
    <#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
    <#else>
public class ${table.controllerName} {
    </#if>

    @Autowired
    private ${table.serviceImplName} ${table.serviceImplName?uncap_first};

    @ApiOperation("分页")
    @PostMapping("/page")
    public R<PageData<${entity}>> page(@RequestBody PageParam<${entity}> pageParam) {
        return ${table.serviceImplName?uncap_first}.page(pageParam);
    }

    @ApiOperation("获取")
    @GetMapping("/get/{id}")
    public R<${entity}> get(@PathVariable("id") Integer id) {
        return ${table.serviceImplName?uncap_first}.get(id);
    }

    @ApiOperation("新增")
    @PostMapping("/add")
    public R add(@RequestBody ${entity} ${entity?uncap_first}) {
        return ${table.serviceImplName?uncap_first}.add(${entity?uncap_first});
    }

    @ApiOperation("修改")
    @PostMapping("/modify")
    public R modify(@RequestBody ${entity} ${entity?uncap_first}) {
        return ${table.serviceImplName?uncap_first}.modify(${entity?uncap_first});
    }

    @ApiOperation("删除")
    @DeleteMapping("/delete/{id}")
    public R delete(@PathVariable("id") Integer id) {
        return ${table.serviceImplName?uncap_first}.delete(id);
    }

    @ApiOperation("导出excel")
    @PostMapping("/exportExcel")
    public void exportExcel(@RequestBody ${entity} ${entity?uncap_first}, HttpServletRequest request, HttpServletResponse response) {
        ${table.serviceImplName?uncap_first}.exportExcel(${entity?uncap_first}, request, response);
    }

    @ApiOperation("导入excel")
    @PostMapping("/importExcel")
    public void importExcel(@RequestParam MultipartFile file) {
        ${table.serviceImplName?uncap_first}.importExcel(file);
    }

    @ApiOperation("下载导入excel模板")
    @GetMapping("/downloadImportExcel")
    public void downloadImportExcel(HttpServletRequest request, HttpServletResponse response) {
        ${table.serviceImplName?uncap_first}.downloadImportExcel(request, response);
    }

}
</#if>
